import request from '@/config/axios'
import { InputNumberProps } from 'element-plus'

export interface GuestbookVO {
  id: number
  siteId: number
  replyUserId: number
  guestbookType: number
  title: string
  msgText: string
  replyText: string
  replyDate: Date
  contactUser: string
  nickname: string
  msgPhone: string
  msgEmail: string
  msgAddress: string
  msgIp: string
  isOpen: number
  isReplied: number
  recommended: number
  status: number
  userId: number
}

export interface GuestbookStatusVO {
  ids: number[]
  status: number
}
export interface GuestbookOpenVO {
  ids: number[]
  isOpen: number
}
export interface GuestbookRecommendedVO {
  ids: number[]
  recommended: number
}

// 查询留言板列表
export const getGuestbookPage = async (params) => {
  return await request.get({ url: '/cms/guestbook/page', params })
}

// 查询留言板详情
export const getGuestbook = async (id: number) => {
  return await request.get({ url: '/cms/guestbook/get?id=' + id })
}

// 新增留言板
export const createGuestbook = async (data: GuestbookVO) => {
  return await request.post({ url: '/cms/guestbook/create', data })
}

// 修改留言板
export const updateGuestbook = async (data: GuestbookVO) => {
  return await request.put({ url: '/cms/guestbook/update', data })
}
// 批量修改留言板状态
export const updateGuestbookStatus = async (data: GuestbookStatusVO) => {
  return await request.post({ url: '/cms/guestbook/batchUpdateStatus', data })
}
// 批量修改留言板公开
export const updateGuestbookOpen = async (data: GuestbookOpenVO) => {
  return await request.post({ url: '/cms/guestbook/batchUpdateOpen', data })
}
// 批量修改留言板推荐
export const updateGuestRecommend = async (data: GuestbookRecommendedVO) => {
  return await request.post({ url: '/cms/guestbook/batchUpdateRecommend', data })
}

// 删除留言板
export const deleteGuestbook = async (id: number) => {
  return await request.post({ url: '/cms/guestbook/delete?id=' + id })
}

// 批量删除留言板
export const deleteGuestbooks = async (ids: number[]) => {
  return await request.post({ url: '/cms/guestbook/deleteGuestbooks', data: ids })
}

// 查询留言板待回复数量
export const getGuestbookToReply = async () => {
  return await request.get({ url: '/cms/guestbook/getToReplyCount' })
}

// 导出留言板 Excel
export const exportGuestbookApi = async (params) => {
  return await request.download({ url: '/cms/guestbook/export-excel', params })
}
